#!/bin/bash

if [ ! -f /opt/rpan-settings/logs/service_start.log ]; then touch /opt/rpan-settings/logs/service_start.log; fi
if [ ! -f /opt/rpan-settings/logs/java_gc.log ]; then touch /opt/rpan-settings/logs/java_gc.log; fi
#nohup java -XX:+UseConcMarkSweepGC -Xmx2048m -Xms1024m  -XX:+PrintGCDateStamps -XX:+PrintGCDetails -Xloggc:./logs/java_gc.log -XX:-HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=./logs/ -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8 -jar api.jar --spring.profiles.active=default > nohup.out &
nohup java -XX:+UseConcMarkSweepGC -Xmx2048m -Xms128m -XX:+PrintGCDateStamps -XX:+PrintGCDetails -Xloggc:/opt/rpan-settings/logs/java_gc.log -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=12222 -Duser.timezone=Asia/Shanghai -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8 -jar app.jar --spring.profiles.active=default &
if [ $? -ne 0 ]; then
   echo -e "\033[31m[`date +"%Y-%m-%d %H:%M:%S"`] ERROR: rpan-settings start fail!!!\033[0m"
   exit 1
else
   echo -e "[`date +"%Y-%m-%d %H:%M:%S"`] INFO: Begin start rpan-settings ..." >> /opt/rpan-settings/logs/service_start.log
fi
tail -Fn 1000 /opt/rpan-settings/logs/service_start.log
#启动filebeat收集日志
#nohup ./filebeat/filebeat -e -c ./filebeat/filebeat.yml >./logs/filebeat.out
